using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Han.Forms
{
    public partial class frmMasrafGirisMini : DevExpress.XtraEditors.XtraForm
    {
        public frmMasrafGirisMini()
        {
            InitializeComponent();
        }
        
        public Masraf ShowDialog(Kontrat kontrat)
        {
            KontratData = kontrat;

            if (this.ShowDialog() == DialogResult.OK)
            {
                return masrafBindingSource.Current as Masraf;  
            }

            return null; 
        }

        public Kontrat KontratData { get; set; }

        DBDataContext db = Program.db;  
        private void frmMasrafGirisMini_Load(object sender, EventArgs e)
        {
            masrafBindingSource.DataSource = new Masraf();
            masrafKalemBindingSource.DataSource = db.MasrafKalems;
            kontratBindingSource.DataSource = db.Kontrats; 
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var masraf =  masrafBindingSource.Current as Masraf;
            
            KontratData.Masrafs.Add(masraf);
            
            this.DialogResult = DialogResult.OK; 
            this.Close(); 
        }

        private void MasrafKalemLookUpEdit_Properties_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Tag == null)
                return; 

            frmMasrafKalemiDuzenle frm = new frmMasrafKalemiDuzenle(db.MasrafKalems);
            frm.Show(); 
        }
    }
}